const useFlatTreeData = (treeData, flatData = []) => {
  treeData.forEach((el) => {
    if (el.children && el.children.length) {
      useFlatTreeData(el.children, flatData);
    } else {
      flatData.push(el);
    }
  });
  return flatData;
};

export default useFlatTreeData;
